/**
 * Created by python on 19-1-13.
 */
/**
 * Created by python on 19-1-11.
 */
/**
 * Created by python on 19-1-11.
 */
var vm = new Vue({
    el: '#app2',
    // 声明Vue使用的模板变量语法
    delimiters: ['[[', ']]'],
    data: {
        host,
        username: sessionStorage.username || localStorage.username,
        user_id: sessionStorage.user_id || localStorage.user_id,
        token: sessionStorage.token || localStorage.token,
        my_data: [],
        label_list: [],
        list_lengh:'',

    },
    mounted: function () {
        // this.get_cart();
        this.get_data()
    },
    methods: {
        get_data: function () {
            // alert('进入函数')
            axios.get(this.host + '/questions/', {
                responseType: 'json'
            })
                .then(response => {
                    alert('请求成功')




                    // alert(response.data)

                    this.my_data = response.data;
                    for (x=0;x++;x<Object.keys(this.my_data[x]).length){
                        // alert(1)
                    }

                    this.list_lengh = Object.keys(this.my_data).length
                    // alert(response.data[0].q_text);
                    for (var j = 0; j < response.data.length; j++) {


                        for (var i = 0; i < this.my_data[j].labels.length; i++) {

                            // alert(this.my_data[0].labels.length)
                            if (this.label_list.indexOf(this.my_data[j].labels[i]) == -1){


                            this.label_list.push(this.my_data[j].labels[i]);

                        }}
                    }

                    // alert(my_data[0].q_text)


                })
                .catch(error => {
                    console.log(error.response.data);
                })
        }
    }
});
